<!-- 安全培训考试 -->
<template>
	<view class="p-2">
		<view v-if="dataList.length>0">
			<exam-item class="mb-3" :item="exam" :key="exam.id" v-for="exam in dataList" :show-arrow='true' @click="gotoDetail(exam)"></exam-item>
		</view>
		<u-empty v-else></u-empty>
	</view>
</template>

<script>
	import examItem from "./components/exam-item.vue"
	import { examPapers } from "@/api/system/study"
	export default {
		components:{examItem},
		onNavigationBarButtonTap(e){
			uni.navigateTo({
				url:'/pages/enter/education/start-exam?projectId='+this.projectId
			})
		},
		onLoad(options){
			this.projectId = options.projectId
		},
		data() {
			return {
				projectId:'',
				dataList:[],
				
			}
		},
		mounted() {
			this.getData()
			uni.$on("refresh-exam", ()=>{
				this.dataList = []
				this.getData()
			})
		},
		methods: {
			getData(){
				examPapers(this.projectId).then(res=>{
					this.dataList = res.data;
				})
			},
			gotoDetail(exam){
				uni.navigateTo({
					url:"/pages/enter/education/exam-detail?pid="+exam.id
				})
			}
		}
	}
</script>

<style>

</style>
